package com.spddr.pmos.cxf.impl;

import java.util.Collection;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Service;

import com.spddr.pmos.cxf.JaxrsPlant;
import com.spddr.pmos.jpa.Plant;
import com.spddr.pmos.jpa.Substation;
import com.spddr.pmos.jpa.Unit;
import com.spddr.pmos.repos.PlantRepos;
import com.spddr.pmos.repos.SubstationRepos;
import com.spddr.pmos.repos.UnitRepos;

@Service
public class JaxrsPlantImpl extends AbstractJaxrsObjectImpl<Plant> implements JaxrsPlant {
	@Autowired
	private PlantRepos repository;

	@Autowired
	private UnitRepos unitRepos;
	@Autowired
	private SubstationRepos substationRepos;

	@Override
	public JpaRepository<Plant, Long> getRepository() {
		return repository;
	}

	@Override
	public Collection<Unit> units(long plant) {
		return unitRepos.findByPlantId(plant);
	}

	@Override
	public Collection<Substation> substations(long plant) {
		return substationRepos.findByPlantId(plant);
	}
}
